package com.starbaba.accountTool.view;

import java.io.IOException;
import java.util.List;

import com.base.common.log.LogService;
import com.opensymphony.xwork2.ModelDriven;
import com.starbaba.accountTool.model.AccountBillRecord;
import com.starbaba.accountTool.service.AccountBillService;
import com.starbaba.accountTool.service.impl.AccountBillServiceImpl;
import com.starbaba.core.utils.PropertyParamMapBuilder;
import com.starbaba.core.utils.Struts2Utils;
import com.starbaba.core.utils.json.JsonUtils;
import com.starbaba.core.web.page.PageResponse;
import com.starbaba.core.web.struts2.BaseAction;

/**
 * 还款提醒用户信息 action
 * @author chenweijun 2017/11/01
 *
 */
@SuppressWarnings({"unchecked","rawtypes"})
public class AccountBillAction extends BaseAction implements ModelDriven<AccountBillRecord>{

	private static final long serialVersionUID = 4741684620585781577L;
	
	private AccountBillService service;
	
	private AccountBillRecord model;
	
	public AccountBillAction(){
		this.service = new AccountBillServiceImpl();
	}
	
	@Override
	public AccountBillRecord getModel() {
		if(model == null){
			model = new AccountBillRecord();
		}
		return null;
	}
	
	/**
	 * 查询列表
	 */
	public void getList(){
		
		parsePageRequest();
		PageResponse pageResponse=new PageResponse();
		paramsMap=PropertyParamMapBuilder.buildFromHttpRequest(Struts2Utils.getRequest(), paramsMap);
		
		List<AccountBillRecord> list = service.getList(paramsMap, pageRequest.getIDisplayStart(),pageRequest.getIDisplayLength());
		int count = service.countList(paramsMap);
		try {
			pageResponse.setITotalDisplayRecords(count);
			pageResponse.setITotalRecords(count);
			pageResponse.setAaData(list);
			sendJsonMessage(JsonUtils.toJson(pageResponse, null, true, null, false));
		} catch(IOException e) {
			LogService.error(e);
		}
		
		
	}

}
